\section{JYD Model}

This model provides an interface to phase2 data stored using the JYD/Hybrid object serialization database. In this DB the top level objects are stored via JYD'd persistence mechanism, while objects below proposal are stored via Java serialization. There are a number of problems to solve with this implementation.

\begin{itemize}

\item The objects extracted from the DB do not conform exactly with the new Phase2 interfaces - i.e. they do not implement {\tt IProposal} or {\tt IMutableProposal} etc. There will therefore need to be some form of translation - e.g. from {\tt ngat.phase2.Group} to something that implements {\tt ngat.phase2.IMutableGroup} etc.

\item Importantly, the stored DB objects do not possess a unique (long) ID field - this will have to be modelled and persisted somehow by the JYDPhase2Model. Since it is an immutable field it can be assigned once and for all for any new objects stored but will have to be generated {\emph on-the-fly} or {\emph first run} for any currently persisted objects.

\item 

\end{itemize}

Here I discuss the implementation details for each accessor method.

\subsection{findUser}
findUser(String userName)

Extract the user via the database transaction mechanism and translate. Obtain the userID via the mapping mechanism and insert into IUsers.


\subsection{listTags}
listTags()

Extract the tags via the database transaction mechanism and translate. Obtain the tagIDs via the mapping mechanism and insert into ITags. Return the list of ITags.

\subsection{getTag}
getTag(tagID)



\subsection{listUsers}
listUsers()

\subsection{getUser}
getUser(userID)

\subsection{listPrograms}
listPrograms()

\subsection{getProgram}
getProgram(programID)

\subsection{listProposalsForTag}
listProposalsForTag(tagID)

\subsection{listProposalsForUser}
listProposalsForUser(userID)

\subsection{listProposalsForProgram}
listProposalsForProgram(programID)

\subsection{getProposal}
getProposal(propID)

\subsection{listGroups}
listGroups(propID)

\subsection{getGroup}
getGroup(groupID)

\subsection{getHistoryItems}
getHistoryItems(groupID)

\subsection{listTargets}
listTargets(propID)

\subsection{getTarget}
getTarget(targetID)

\subsection{listObs}
listObs(groupID)

\subsection{getObs}
getObs(obsID)

\subsection{listAccounts}
listAccounts(propID) 

\subsection{getAccount}
getAccount(accountID)

\subsection{listPeriods}
listPeriods(accountID)

\subsection{getPeriod}
getPeriod(periodID)

\subsection{listTransactions}
listTransactions(periodID)

\subsection{getTransaction}
getTransaction(transID)

\subsection{lockGroup}
lockGroup(groupID, clientID): keyID

\subsection{unlockGroup}
unlockGroup(groupID, keyID)

\subsection{lockTarget}
lockTarget(targetID, clientID): keyID

\subsection{unlockTarget}
unlockTarget(targetID, keyID)

\subsection{lockAccount}
lockAccount(accountID, clientID): keyID

\subsection{unlockAccount}
unlockAccount(accountID, keyID)

\subsection{createUser}
createUser(User): userID

\subsection{updateUser}
updateUser(User))

\subsection{deleteUser}
deleteUser(userID)

\subsection{createTag}
createTag(Tag): tagID

\subsection{updateTag}
updateTag(Tag)

\subsection{deleteTag}
deleteTag(tagID

\subsection{createProgram}
createProgram(Program): programID

\subsection{updateProgram}
updateProgram(Program)

\subsection{deleteProgram}
deleteProgram(programID)

\subsection{createProposal}
createProposal(Proposal): propID

\subsection{updateProposal}
updateProposal(Proposal)

\subsection{deleteProposal}
deleteProposal(propID)

\subsection{createAccount}
createAccount(Account): accountID

\subsection{updateAccount}
updateAccount(Account)

\subsection{deleteAccount}
deleteAccount(accountID)

\subsection{createPeriod}
createPeriod(Period): periodID

\subsection{updatePeriod}
updatePeriod(Period)

\subsection{deletePeriod}
deletePeriod(periodID)

\subsection{performTransaction}
 tranIDperformTransaction(periodID, Transaction): tranID

\subsection{createGroup}
groupIDcreateGroup(Group): groupID

\subsection{updateGroup}
updateGroup(Group)

\subsection{deleteGroup}
deleteGroup(groupID)

\subsection{appendHistory}
appendHistory(groupID, HistoryItem): histID

\subsection{createObs}
obsIDcreateObs(Obs): obsID

\subsection{updateObs}
updateObs(Obs)

\subsection{deleteObs}
deleteObs(obsID)

\subsection{createTarget}
targetIDcreateTarget(Target): targetID

\subsection{updateTarget}
updateTarget(Target)

\subsection{deleteTarget}
deleteTarget(targetID)
